<?php
/**
 * Created by PhpStorm.
 * User: weijer
 * Date: 2018/10/26
 * Time: 21:17
 */

namespace common\validate;

use think\Validate;

class Oauth extends BaseValidate
{
    //验证规则
    protected $rule = [];


    // SelectClient 验证场景定义
    public function sceneSelectClient()
    {
        return $this->append('param', 'array')
            ->append('param.page', 'array');
    }

    // AddClientWithMedia 验证场景定义
    public function sceneAddClientWithMedia()
    {
        return $this->append('data', 'require')
            ->append('data.name', 'require')
            ->append('data.home_uri', 'require')
            ->append('data.redirect_uri', 'require')
            ->append('data.active', 'in:0,1')
            ->append('data.resource_ids', 'max:255')
            ->append('data.scope', 'in:read,write')
            ->append('data.grant_types', 'max:80')
            ->append('data.register', 'in:0,1')
            ->append('data.register_api', 'max:128')
            ->append('data.set_user_api', 'max:128')
            ->append('data.role_api', 'max:128')
            ->append('media', 'array');
    }

    // ModifyClientWithMedia 验证场景定义
    public function sceneModifyClientWithMedia()
    {
        return $this->append('data', 'require|array')
            ->append('filter', 'require|array')
            ->append('media', 'array');
    }

    // DeleteClient 验证场景定义
    public function sceneDeleteClient()
    {
        return $this->append('param.filter', 'require|array');
    }

    // SwitchClientActive 验证场景定义
    public function sceneSwitchClientActive()
    {
        return $this->append('param.filter', 'require|array');
    }

    // SyncRegister 验证场景定义
    public function sceneSyncRegister()
    {
        return $this
            ->append("data.name", 'require')
            ->append("data.phone", 'require')
            ->append("data.password", 'require');
    }

    // SendSMS 验证场景定义
    public function sceneSendSMS()
    {
        return $this
            ->append("phone", 'require')
            ->append("verify_code", 'require')
            ->append("type", 'require|in:register,login,forgot');
    }

    // RemoteVerifyLogin 验证场景定义
    public function sceneRemoteVerifyLogin()
    {
        return $this
            ->append("data.phone", 'require')
            ->append("data.password", 'require');
    }

    // SendSystemNoticeMessage 验证场景定义
    public function sceneSendSystemNoticeMessage()
    {
        return $this
            ->append('data.type', 'require')
            ->append('data.receiver', 'require|integer|gt:1')
            ->append('data.content', 'require')
            ->append('data.content_type', 'require');
    }

    // RenderMessageTemplate 验证场景定义
    public function sceneRenderMessageTemplate()
    {
        return $this
            ->append('template_id', 'require')
            ->append('param', 'require|array');
    }

    // CreateChat 验证场景定义
    public function sceneCreateChat()
    {
        return $this
            ->append('data', 'require|array')
            ->append('data.chat', 'require|array')
            ->append('data.chat.type', 'require')
            ->append('data.chat_users', 'array')
            ->append('data.owner', 'require|integer');
    }

    // DeleteChatUser 验证场景定义
    public function sceneDeleteChatUser()
    {
        return $this
            ->append('param.filter', 'require|array');
    }

    // InviteChatUser 验证场景定义
    public function sceneInviteChatUser()
    {
        return $this
            ->append('data', 'require|array')
            ->append('data.user_id', 'require|array')
            ->append('data.chat_global_id', 'require');
    }

    // FindChat 验证场景定义
    public function sceneFindChat()
    {
        return $this
            ->append('param.filter', 'require|array');
    }

    // DeleteChat 验证场景定义
    public function sceneDeleteChat()
    {
        return $this
            ->append('param.filter', 'require|array');
    }

    // ClearUserTokenByDeviceCode 验证场景定义
    public function sceneClearUserTokenByDeviceCode()
    {
        return $this->append("param.device_unique_code", "require");
    }

    // SendDataToUserChannel 验证场景定义
    public function sceneSendDataToUserChannel()
    {
        return $this
            ->append('param.filter', 'require|array')
            ->append('param.data', 'require');
    }

    // clearTokenByDeviceCode 验证场景定义
    public function sceneClearTokenByDeviceCode()
    {
        return $this->append("device_unique_code", "require");
    }

    // MarkTenantFrameworkAgreementStatus 验证场景定义
    public function sceneMarkTenantFrameworkAgreementStatus()
    {
        return $this->append("data", "require");
    }

}
